public class test2 {
    //力扣 35.搜索插入位置
    public static void main(String[] args) {
        int[] arr = {1,3,5,6};
        System.out.println(searchInsert(arr, 7));
    }
    public static int searchInsert(int[] nums, int target) {
        if(nums.length==0){
            return 0;
        }
        int left = 0,right = nums.length-1,mid = 0;
        while(left<right){
            mid = left+(right - left )/2;
            if(nums[mid]<target){
                left = mid+1;
            }else{
                right = mid;
            }
        }
        if(nums[left]<target){
            return left+1;
        }
        return left;
    }
}
